# OddEvenEncryption_v2.py # # Description: Write a program that encrypts and decrypts messages # using a transposition algorithm called "odd&even". # # Anne Lavergne # Date: Feb. 2 2024 # Ask the user for a message to encrypt/decrypt plainMsg = input("Please, enter a message to encrypt/decrypt: ") # ***Encryption*** # Create two empty strings strOfOddChars = "" strOfEvenChars = "" # Start with position (i.e., index) 0 index = 0 # Consider each character in the user's plain message for char in plainMsg: # If index of character is odd if index % 2 == 1: # Put this character in strOfOddChars strOfOddChars = strOfOddChars + char # strOfOddChars =+ char else: # Otherwise put it in strOfEvenChars strOfEvenChars = strOfEvenChars + char # strOfEvenChars =+ char # Go to the next position (i.e., index) in user's plain message index = index + 1 # index += 1 # When finish, create the cipher cipherMsg = strOfOddChars + strOfEvenChars # Print the cipherMsg, i.e., the encrypted user message print(f'''\nThe original plain message you entered was "{plainMsg}". Once encrypted, your message looked like this "{cipherMsg}".''')